package chapter1104;

public class TestEmployee {
    public static void main(String[] args) {
        Employee[] employee = new Employee[5];

        //不能生成抽象类employee
//        Employee[0] = new Employee();
        employee[1] = new SalariedEmployee("A",2,6000);
        employee[2] = new HourlyEmployee("B",3,100,150);
        employee[3] = new SalesEmployee("C",4,4000,0.5);
        employee[4] = new BasePlusSalesEmployee("D",5,2000,0.5,10000);

        //想要修改时薪，需要强制类型转换成子类,再调用set方法
        System.out.println(employee[2].getName() + "  " + employee[2].getSalary(1));
        ((HourlyEmployee)employee[2]).setHours(10);
        System.out.println(employee[2].getName() + "  " + employee[2].getSalary(1));

        System.out.println("\n\n");

        for(Employee e: employee){
            if(e != null)
                System.out.println(e.getName() + "  " + e.getSalary(1));
//            System.out.println(e.getName() + "  " + Double.toString(e.getSalary(1)));
        }
    }
}
